package com.softline.documentsmall.feign;

import com.alibaba.fastjson.JSONObject;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Feign回退
 * 使用 FallbackFactory 相比 fallback，可以打印出错误日志，方便排查错误
 *
 */
@Slf4j
@Component
public class PassportServiceFallback implements FallbackFactory<PassportService> {

    @Override
    public PassportService create(Throwable throwable) {
        PassportService passportService = new PassportService() {
            @Override
            public JSONObject checkSSO(String passport) {
                log.error("checkSSO调用失败：", throwable);
                //System.out.println("checkSSO调用失败：" + throwable.getMessage());
                return null;
            }
        };
        return passportService;
    }


}